CC = arm-none-eabi-gcc
AS = arm-none-eabi-as

CFLAGS += -march=armv6

all: ethtest.mem ethtest.bin

ethtest.mem: ethtest.bin
	../memfile/bintomem $< $@

ethtest.bin: ethtest.o
	arm-none-eabi-objcopy -O binary -j .start -j .text -j .rodata -j .data \
		$< $@
ethtest.o: ethtest.lds main.o ethmac.o uart.o start.o packet.o isr.o memcpy.o
	$(CC) -o $@ -T $^ -nostdlib -lgcc

main.o: main.c ethmac.h packet.h uart.h timer.h
ethmac.o: ethmac.c ethmac.h packet.h uart.h
uart.o: uart.c uart.h
packet.o: packet.c packet.h ethmac.h
isr.o: isr.c packet.h ethmac.h timer.h

clean:
	rm -f *.o ethtest.{bin,mem}

.PHONY: all clean
